function flowc_est_demo()
% A simple program to demo how to estimate flow coefficients
%
%   FLOWC_EST_DEMO;
%

%% prepare a (ground-truth) flow

dx = 0.1;
dy = 0.1;
xv = -25 : dx : 25;
yv = -25 : dy : 25;

VBas = affine_vbasis(xv, yv, {'xt', 'yt', 'ro'});
K = VBas.K;

alpha0 = randn(K, 1);

cxt = alpha0(1);
cyt = alpha0(2);
cro = alpha0(3);

%% generate image sequence

imf = @(x, y) 0.5 * sin(x / 20) .* cos(y / 20) + 0.5;

dt = 0.1;
ts = 0 : dt : dt * 10;

X = [0, -0.5 * cro, cxt; 0.5 * cro, 0, cyt];
imgs = affine_seq(imf, xv, yv, X, ts);

%% perform estimation

alpha = flowc_from_imgs(VBas, imgs, dx, dy, dt);

disp('Compare result with ground-truth:');
display(alpha0);
display(alpha);

fprintf('norm(alpha - alpha0) = %.4g\n', norm(alpha - alpha0));
disp(' ');


